﻿//======================================================
//==     (c)2008 aspxcms inc by NeTCMS v1.0              ==
//==          Forum:bbs.aspxcms.com                   ==
//==         Website:www.aspxcms.com                  ==
//======================================================
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using NetCMS.Content;

namespace NetCMS.Web.manage.adapt
{
    public partial class adapt : NetCMS.Web.UI.ManagePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
       
        protected void submit_Click(object sender, EventArgs e)
        {
            if (Api_Enable.Checked)
            {
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    string xmlName = Server.MapPath("../../api/dz/Adapt.config");
                    xmlDoc.Load(xmlName);
                    XmlNode xn = xmlDoc.SelectSingleNode("adapt");
                    XmlElement xeIsAdapt = (XmlElement)xn.SelectSingleNode("isAdapt");                    
                    XmlElement xeAdaptKey = (XmlElement)xn.SelectSingleNode("adaptKey");
                    XmlElement xePagePath = (XmlElement)xn.SelectSingleNode("adaptPath");
                    xeIsAdapt.InnerText = "true";
                    xeAdaptKey.InnerText = Api_Key.Text.Trim();
                    xePagePath.InnerText = Api_Urls.Text.Trim();
                    xmlDoc.Save(xmlName);                    
                }
                catch (Exception Ex)
                {
                    Response.Write(Ex.Message);
                }
            }
            else
            {
                try
                {
                    XmlDocument xmlDoc = new XmlDocument();
                    string xmlName = Server.MapPath("../../api/dz/Adapt.config");
                    xmlDoc.Load(xmlName);
                    XmlNode xn = xmlDoc.SelectSingleNode("adapt");
                    XmlElement xeIsAdapt = (XmlElement)xn.SelectSingleNode("isAdapt");
                    if (xeIsAdapt.InnerText.Trim() == "true")
                    {
                        xeIsAdapt.InnerText = "false";
                    }
                    xmlDoc.Save(xmlName);                    
                }
                catch (Exception Ex)
                {
                    Response.Write(Ex.Message);
                }
            }
        }
    }
}
